//
//  RACHomeViewController.m
//  LockTest
//
//  Created by ZhangBo on 2018/12/3.
//  Copyright © 2018 ZhangBo. All rights reserved.
//

#import "RACHomeViewController.h"

// 命令式编程  寄存器+运算（申请内存、计算内存，注重过程，执行效率高）
// 函数式编程  函数 （重在表达，更注重业务）
// 响应式编程  一个变量伴随着另外一个变量的变化而变化
int factorialMult(int x) {
    int result = 1;
    for (int i = 1; i <= x; i++) {
        result *= i;
    }
    return result;
}

int factorialMultTwo(int x) {
    if (x == 1) return 1;
    return x * factorialMultTwo(x - 1);
}


int maxInArr(int *array, int count) {
    if (count == 1) return array[0];
    int max = maxInArr(array, count - 1);
    return max > array[count - 1] ? max : array[count - 1];
}

typedef int (^CompareBlock)(int aValue, int aNext);

int minInArr(int *array, int count, CompareBlock block) {
    if (count == 1) return array[0];
    int min = minInArr(array, count - 1, block);
    return min;
}


@interface RACHomeViewController ()

@end

@implementation RACHomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)signalUnit {

}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    int array[5] = {5, 6, 7, 8, 1};
    NSLog(@"%zi", (ssize_t) maxInArr(array, 5));


}

@end
